home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CSICNPane 1.0 / CSICNButton / CSICNButton.c next >
Encoding:
Text File  |  1994-11-30  |  2.7 KB  |  116 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CSICNButton.c
  3.  
  4.     Creates a pane containing a SICN. The pane can act as a button simply by
  5.     setting SetClickCmd() to something other then cmdNull.
  6.     
  7.     BROWN UNIVERSITY AND ANDREW JAMES GILMARTIN GIVE NO WARRANTY, EITHER
  8.     EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
  9.     INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
  10.     WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
  11.  
  12.     AUTHOR: Andrew_Gilmartin@Brown.Edu
  13.     MODIFIED: 93-04-14
  14.  
  15. ******************************************************************************/
  16.  
  17. //#include <TCLHeaders>
  18. #include "CSICNButton.h"
  19. #include "TrackMouseClick.h"
  20.  
  21.  
  22.  
  23. /******************************************************************************
  24.  ISICNButton
  25.  
  26.     Initialize CSICNButton. Pane does not act like a button by default.
  27. ******************************************************************************/
  28.  
  29. void CSICNButton::ISICNButton
  30.     ( CView *anEnclosure
  31.     , CBureaucrat *aSupervisor
  32.     , short aHEncl
  33.     , short aVEncl
  34.     , SizingOption aHSizing
  35.     , SizingOption aVSizing
  36.     , short SICNid
  37.     , short SICNindex )
  38. {
  39.     ISICNPane
  40.         ( anEnclosure
  41.         , aSupervisor
  42.         , aHEncl
  43.         , aVEncl
  44.         , aHSizing
  45.         , aVSizing
  46.         , SICNid
  47.         , SICNindex );
  48.         
  49.     SetClickCmd( cmdNull );
  50.     
  51. } /* ISICNButton */
  52.  
  53.  
  54.  
  55. /******************************************************************************
  56.  DoClick
  57.  
  58.     When acting as a button, track mouse. Call DoGoodClick() if successful.
  59. ******************************************************************************/
  60.  
  61. void CSICNButton::DoClick( Point hitPt, short modifierKeys, long when )
  62. {
  63.     Rect theFrame;
  64.  
  65.     LongToQDRect( &frame, &theFrame );
  66.     
  67.     if ( TrackMouseClick( &theFrame, FALSE /* Don't flash */ ) )
  68.         DoGoodClick( 0 );
  69.  
  70. } /* DoClick */
  71.  
  72.  
  73.  
  74. /******************************************************************************
  75.  DoGoodClick
  76.  
  77.     Send the command to the supervisor
  78. ******************************************************************************/
  79.  
  80. void CSICNButton::DoGoodClick( short whichPart )
  81. {
  82.     itsSupervisor->DoCommand( fCommand );
  83.  
  84. } /* DoGoodClick */
  85.  
  86.  
  87.  
  88. /******************************************************************************
  89.  SetClickCmd
  90.  
  91.     Set the command to be sent upon a good click.
  92. ******************************************************************************/
  93.  
  94. void CSICNButton::SetClickCmd( long command )
  95. {
  96.     fCommand = command;
  97.  
  98.     SetWantsClicks( fCommand != cmdNull );
  99.  
  100. } /* SetClickCmd */
  101.  
  102.  
  103.  
  104. /******************************************************************************
  105.  GetClickCmd
  106.  
  107.     Get the current good click command.
  108. ******************************************************************************/
  109.  
  110. long CSICNButton::GetClickCmd( void )
  111. {
  112.     return fCommand;
  113.  
  114. } /* GetClickCmd */
  115.  
  116.